﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JXT.PrimaryKey.Batman.Collections;
using JXT.PrimaryKey.Batman.Domain.Repositories;
using JXT.PrimaryKey.Batman.Domain.Specifications;
using JXT.PrimaryKey.Batman.Domain.Quotation.Models;

namespace JXT.PrimaryKey.Batman.Domain.Quotation.Repositories
{
    /// <summary>
    /// 实时交易数据存储
    /// </summary>
    public interface IRealTimeQuoteRepository : IRepository<RealTimeQuote>
    {
        /// <summary>
        /// 增加一条新的实时交易数据
        /// </summary>
        /// <param name="entity">交易数据</param>
        void Add(RealTimeQuote entity);

        /// <summary>
        /// 批量写入实时交易数据
        /// </summary>
        /// <param name="list">数据集合</param>
        void Add(IEnumerable<RealTimeQuote> list);

        /// <summary>
        /// 统计数据数量
        /// </summary>
        /// <param name="type">交易所类型</param>
        /// <param name="date">更新日期（日期部分有效）</param>
        /// <returns></returns>
        int Count(MarketType type, DateTime date);

        /// <summary>
        /// 获取指定股票的当前交易数据
        /// </summary>
        /// <param name="code">股票代码</param>
        /// <param name="type">交易所类型</param>
        /// <returns>实时交易数据</returns>
        RealTimeQuote GetSingle(string code, MarketType type = MarketType.Unknown, DateTime? date = null);

        /// <summary>
        /// 获取指定股票指定时间段的交易记录
        /// </summary>
        /// <param name="code">股票代码</param>
        /// <param name="type">市场类型</param>
        /// <param name="startTime">开始时间，为空则为当日0时</param>
        /// <param name="endTime">结束时间，为空则取到最新记录为止</param>
        /// <returns>实时数据集合</returns>
        IEnumerable<RealTimeQuote> GetList(string code, MarketType type = MarketType.Unknown, DateTime? startTime = null, DateTime? endTime = null);
    }
}
